package ge.modules.events;

import java.util.ArrayList;


import ge.lowlevel.CollisionEngine;
import ge.lowlevel.EventEngine;
import ge.modules.Module;

/**
 * 	
 * @author Abel
 *	All modules inherits from EventModule will be automatically attached to the Event Engine.
 */
public abstract class EventModule implements Module 
{
	private ArrayList<String> eventMethods;
	private int id = 0;
	public EventModule()
	{
		EventEngine.get().attach(this);
		eventMethods = new ArrayList<String>();
	}
	/**
	 * 	Attach a name of a method the class is going to be asked during the execution.
	 * @param name Name of the method
	 */
	protected void attachMethod(String method)
	{
		eventMethods.add(method);
	}
	/**
	 * 	Ask the event module for a method
	 * @param method Name of the method
	 * @return	true if it has the method
	 */
	public boolean ask(String method)
	{
		return eventMethods.contains(method);
	}
	/**
	 * 	The id allows you to be identified between others EventModules of the same type
	 * @param id Identify number
	 */
	protected void setId(int id)
	{
		this.id = id;
	}
	/**
	 * 	The id identify a EventModule between others whit the same type
	 * @return Id, whose default value it's 0 (no id)
	 */
	public int getId()
	{
		return id;
	}
	@Override
	public void delete()
	{
		 EventEngine.get().remove(this);
	}
}
